package com.basic.business.clickFarmingRecord.controller;


import java.util.List;
import java.io.IOException;

import com.basic.business.clickFarmingRecord.domain.TClickFarmingRecord;
import com.basic.business.clickFarmingRecord.service.ITClickFarmingRecordService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import com.basic.common.annotation.FileExport;
import com.basic.common.utils.easyExcel.EasyExcelUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.basic.common.annotation.Log;
import com.basic.common.core.controller.BaseController;
import com.basic.common.core.domain.AjaxResult;
import com.basic.common.enums.BusinessType;
import com.basic.common.core.page.TableDataInfo;

/**
 * 刷单数据记录Controller
 *
 * @author zhaoxy_jn@163.com
 */
@RestController
@RequestMapping("/business/clickFarmingRecord")
public class TClickFarmingRecordController extends BaseController
{
    @Resource
    private ITClickFarmingRecordService tClickFarmingRecordService;

    /**
     * 查询刷单数据记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:clickFarmingRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(TClickFarmingRecord tClickFarmingRecord)
    {
        startPage();
        List<TClickFarmingRecord> list = tClickFarmingRecordService.getList(tClickFarmingRecord);
        return getDataTable(list);
    }

    /**
     * 导出刷单数据记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:clickFarmingRecord:export')")
    @Log(title = "刷单数据记录", businessType = BusinessType.EXPORT)
    @FileExport(fileName = "刷单数据记录.xlsx")
    @PostMapping("/export")
    public String export(TClickFarmingRecord tClickFarmingRecord) throws IOException
    {
        List<TClickFarmingRecord> list = tClickFarmingRecordService.getList(tClickFarmingRecord);
        return EasyExcelUtils.excelExport(TClickFarmingRecord.class,"刷单数据记录数据", list);
    }

    /**
     * 获取刷单数据记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:clickFarmingRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tClickFarmingRecordService.get(id));
    }

    /**
     * 新增刷单数据记录
     */
    @PreAuthorize("@ss.hasPermi('business:clickFarmingRecord:add')")
    @Log(title = "刷单数据记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TClickFarmingRecord tClickFarmingRecord)
    {
        return toAjax(tClickFarmingRecordService.insert(tClickFarmingRecord));
    }

    /**
     * 修改刷单数据记录
     */
    @PreAuthorize("@ss.hasPermi('business:clickFarmingRecord:edit')")
    @Log(title = "刷单数据记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TClickFarmingRecord tClickFarmingRecord)
    {
        return toAjax(tClickFarmingRecordService.update(tClickFarmingRecord));
    }

    /**
     * 删除刷单数据记录
     */
    @PreAuthorize("@ss.hasPermi('business:clickFarmingRecord:remove')")
    @Log(title = "刷单数据记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tClickFarmingRecordService.deleteByIds(ids));
    }


    /**
     * 定时任务查询处理刷单数据
     */
    @Scheduled(cron = "0 30 2 * * ?")
    public void handleClickFarming() {
        tClickFarmingRecordService.clickFarmingTask();
    }

    /**
     * 定时任务处理刷单数据记录
     */
    @Scheduled(cron = "0 0 3 * * ?")
    public void handleClickFarmingRecord() {
        tClickFarmingRecordService.handleClickFarmingRecord();
    }
}
